package plugin.demo.shardingsphere.seata.config.v5_0_0;

import com.zaxxer.hikari.HikariDataSource;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.jdbc.datasource.DataSourceTransactionManager;
import org.springframework.transaction.annotation.EnableTransactionManagement;

import javax.sql.DataSource;

/**
 * @Author: Qiao Hang
 * @CreateDate: 2021/4/25 下午2:15
 * @UpdateDate:
 * @Description:
 */
@Configuration
@EnableTransactionManagement
//@AutoConfigureAfter(ShardingJDBCAdaptor.class)
public class ShardingTransactionAdaptor {

    @Bean("dataSourceTransactionManager")
    public DataSourceTransactionManager dataSourceTransactionManager(final DataSource dataSource){
        return new DataSourceTransactionManager(dataSource);
    }

    @Bean
    public JdbcTemplate jdbcTemplate(final DataSource dataSource) {
        return new JdbcTemplate(dataSource);
    }
}
